# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=mediaelch
pkgver=2.12.0
pkgrel=0
pkgdesc="Media Manager for Kodi"
url="https://github.com/Komet/MediaElch"
arch="all"
license="LGPL-3.0-only"
depends="qt6-qtbase-sqlite qt6-qtsvg"
makedepends="
	cmake
	qt6-qt5compat-dev
	qt6-qtbase-dev
	qt6-qtdeclarative-dev
	qt6-qtmultimedia-dev
	qt6-qtsvg-dev
	qt6-qttools-dev
	libmediainfo-dev
	curl-dev
	fortify-headers
	quazip-dev
	samurai
	xvfb-run
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/Komet/MediaElch/archive/v$pkgver.tar.gz
	"
builddir="$srcdir/MediaElch-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=Release \
		-DUSE_EXTERN_QUAZIP=true \
		-DDISABLE_UPDATER=ON \
		-DMEDIAELCH_FORCE_QT6=ON \
		-DENABLE_TESTS=ON \
		$CMAKE_CROSSOPTS .
	xvfb-run -a cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run -a ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
b347c313a12e325abe8c5e67cffc53a91fdb87236fb0dca9c8fc4bdd01db3e0028c694ce2766314e38e73df138e2078dd54191593d6c0519f2f719f65c3dda69  mediaelch-2.12.0.tar.gz
"
